<?php

// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));

// Define application environment
defined('APPLICATION_ENV')
    || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));


	
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
    realpath(APPLICATION_PATH . '/../library'),
    get_include_path(),
)));

$rootDir = dirname(dirname(__FILE__));
	   define('ROOT_DIR', $rootDir);
	   set_include_path(get_include_path()
	      .PATH_SEPARATOR . ROOT_DIR . '/library/'
		  .PATH_SEPARATOR . ROOT_DIR .
		     '/application/models/'
	   );

/** Zend_Application */
require_once 'Zend/Application.php';  
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoLoad();
ini_set('display_errors', true);
// Create application, bootstrap, and run
$application = new Zend_Application(
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);

//db config and connect;
$params = array(
					'host' =>'localhost',
					'username' =>'340608',
					'password' =>'20061973',
					'dbname' => '340608'
				);
$db = Zend_Db::factory('mysqli', $params);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
$db->query("SET NAMES 'utf8'");	
Zend_Registry::set('db', $db);

// Set layout
Zend_Layout::startMvc(array(
            'layoutPath' => ROOT_DIR . '/application/layouts',
			));

	$application->bootstrap()
            ->run();
// co 2 ham ho tro debug:
// echo get_include_path();
// co bien ROOT_DIR da dinh nghia --> co the dung duoc


			